package com.mmy.service.impl.restaurant;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.restaurant.TRestaurantOrderRepository;
import com.mmy.domain.restaurant.TRestaurantOrder;
import com.mmy.service.restaurant.TRestaurantOrderService;

@Service
public class TRestaurantOrderServiceImpl implements TRestaurantOrderService {

	@Autowired
	TRestaurantOrderRepository tRestaurantOrderRepository;

	/**
	 * 获取最大流水号
	 * 
	 * @return 返回值说明 流水号
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public int getMaxID() {
		// 流水号
		Object objCode = tRestaurantOrderRepository.getMaxID();
		int iID = 0;
		if (objCode != null) {
			iID = Integer.parseInt(objCode.toString());
		}
		return iID;
	}

	/**
	 * 获取订单最大编码
	 * 
	 * @param 参数说明 计划单编码
	 * @return 返回值说明 订单编码
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public String getMaxCode(int iPlanID) {
		// int 转 string
		String strPlanID = String.valueOf(iPlanID);
		// 返回订单最大编码
		Object objCode = tRestaurantOrderRepository.getMaxCode(strPlanID);
		String strCode = "";
		if (objCode != null) {
			strCode = objCode.toString();
		}
		return strCode;
	}

	/**
	 * 新增id
	 * 
	 * @param
	 * @return
	 */
	public void save(int id) {
		// TODO Auto-generated method stub
		tRestaurantOrderRepository.save(id);
	}

	/**
	 * 新增订单
	 * 
	 * @param
	 * @return
	 */
	public void save(TRestaurantOrder tRestaurantOrder) {
		// TODO Auto-generated method stub
		tRestaurantOrderRepository.save(tRestaurantOrder);
	}

	/**
	 * id查找
	 * 
	 * @param
	 * @return
	 */
	public TRestaurantOrder findByID(int iID) {
		// TODO Auto-generated method stub
		return tRestaurantOrderRepository.findByID(iID);
	}

	/**
	 * 查找餐馆的订单
	 * 
	 * @param
	 * @return
	 */
	public List<TRestaurantOrder> findByRestaurantID(int iRestaurantID) {
		// TODO Auto-generated method stub
		return tRestaurantOrderRepository.findByRestaurantID(iRestaurantID);
	}

	/**
	 * 删除预留
	 * 
	 * @param
	 * @return
	 */
	public void delRestaurantOrder(List<Integer> lstID) {
		// TODO Auto-generated method stub
		tRestaurantOrderRepository.delRestaurantOrder(lstID);
	}

	/**
	 * 出纳查询
	 * 
	 * @param
	 * @return
	 */
	public List<TRestaurantOrder> findByCashierAndRestaurantID(String strCashierState, int iRestaurantID) {
		// TODO Auto-generated method stub
		return tRestaurantOrderRepository.findByCashierAndRestaurantID(strCashierState, iRestaurantID);
	}

	/**
	 * 查找全部
	 * 
	 * @param
	 * @return
	 */
	public List<TRestaurantOrder> findAll() {
		// TODO Auto-generated method stub
		return tRestaurantOrderRepository.findAll();
	}

	/**
	 * 会计查询
	 * 
	 * @param
	 * @return
	 */
	public List<TRestaurantOrder> findByAccountAndRestaurantID(String strAccountState, int iRestaurantID) {
		// TODO Auto-generated method stub
		return tRestaurantOrderRepository.findByAccountAndRestaurantID(strAccountState, iRestaurantID);
	}

	public void saveAll(List<TRestaurantOrder> lstCashier) {
		// TODO Auto-generated method stub
		tRestaurantOrderRepository.saveAll(lstCashier);
	}

	/* 个人中心通过登录人获取餐馆预留 */
	public List<TRestaurantOrder> findByUserID(int userID) {
		// TODO Auto-generated method stub
		// return tRestaurantOrderRepository.findByUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取餐馆订单 */
	public List<TRestaurantOrder> findByOrderUserID(int userID) {
		// TODO Auto-generated method stub
		// return tRestaurantOrderRepository.findByOrderUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取餐馆退单 */
	public List<TRestaurantOrder> findByChargeBackUserID(int userID) {
		// TODO Auto-generated method stub
		// return tRestaurantOrderRepository.findByChargeBackUserID(userID);
		return null;
	}

}
